<?php

HBase::using('Backend.Robot.*');
HBase::using('DAL.*');
HBase::using('Backend.*');

/**
 * Enter description here...
 *
 */
class backend_users_index extends HModule {
	public $page;
	public $data;
	
	function run(){
		if (isset($_POST['flag'])) {
    		self::process();    	
	    }
	    
	    // Get the current table page
		if (!isset($_GET['page'])){
			$this->page = 1;
		}else {
			$this->page = HCommon::xss($_GET['page']);
		}
		// get Paged Data
		$this->data = HUsers::getAllUsersExceptHost();
	}
	
	function process(){
		$username 	= $_POST['tbxUsername'];
		$password 	= $_POST['tbxPassword'];
		$email		= $_POST['tbxEmail'];
		
		if (HUsers::insert($username, md5($password), $email)) {
			HUtil::alert("Add user successfully!");
		}else {
			HUtil::alert("ERROR: Add user unsuccessfully! ");
		}
		HUtil::redirect(HCommon::navigateUrl('Users'));
	}
}
?>